@echo off
chcp 65001 >nul
title AI VTuber Test (Anaconda)

echo ======================================================================
echo                AI VTuber - Test Launcher (Anaconda)
echo ======================================================================
echo.

REM Change to script directory
cd /d "%~dp0"

REM Initialize Anaconda environment
echo Initializing Anaconda environment...
call D:\anaconda\Scripts\activate.bat D:\anaconda
if errorlevel 1 (
    echo.
    echo Warning: Failed to activate Anaconda environment
    echo Trying to run with system Python...
    echo.
)

REM Display Python info
echo Python Environment:
python --version
python -c "import sys; print('Python Path:', sys.executable)"
echo.

REM Check dependencies
echo Checking dependencies...
python -c "import yaml" >nul 2>&1
if errorlevel 1 (
    echo.
    echo Warning: yaml module not found!
    echo Installing dependencies...
    echo.
    pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
    if errorlevel 1 (
        echo.
        echo Error: Failed to install dependencies!
        pause
        exit /b 1
    )
    echo.
)
echo Dependencies OK
echo.

echo ======================================================================
echo                      Starting Test Program
echo ======================================================================
echo.
echo Configuration:
echo   TTS Engine: ChatTTS
echo   Voice: Girl Voice (Seed 5201)
echo   Live2D: Auto Open
echo.
echo Starting...
echo.

REM Run test program
python test_local_enhanced.py

REM Check result
if errorlevel 1 (
    echo.
    echo ======================================================================
    echo Program exited with error!
    echo ======================================================================
    echo.
    pause
    exit /b 1
)

echo.
echo ======================================================================
echo Test completed
echo ======================================================================
echo.
pause
